<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>个人中心</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=yes"/>

		<link rel="stylesheet" href="../css/mui.min.css">
		<style>
			html,
			body {
				background-color: #efeff4;
			}

			.title {
				margin: 20px 15px 10px;
				color: #6d6d72;
				font-size: 15px;
			}

			.oa-contact-cell.mui-table .mui-table-cell {
				padding: 11px 0;
				vertical-align: middle;
			}

			.oa-contact-cell {
				position: relative;
				margin: -11px 0;
			}

			.oa-contact-avatar {
				width: 75px;
			}

			.oa-contact-avatar img {
				border-radius: 50%;
			}

			.oa-contact-content {
				width: 100%;
			}

			.oa-contact-name {
				margin-right: 20px;
			}

			.oa-contact-name,
			oa-contact-position {
				float: left;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav" id="headerbf">
			<h1 class="mui-title">移动病房</h1>
		</header>
		<div class="mui-content">
			<div class="title">
				个人设置中心
			</div>
			<div class="mui-scroll-wrapper">
				<div class="mui-scroll">
					<div style="height:88px;"></div>
					<ul class="mui-table-view mui-table-view-chevron">
						<li class="mui-table-view-cell" onclick="bindCardFunc();">
							<a id="bindCard" class="mui-navigate-right">生成生理体征数据卡</a>
						</li>
						<li class="mui-table-view-cell" onclick="bindObserverPage();">
							<a id="visCard" class="mui-navigate-right">邀请监护人</a>
						</li>
						<li class="mui-table-view-cell" onclick="bindPatientPage();">
							<a id="beiyaoqingCard" class="mui-navigate-right">绑定患者</a>
						</li>
						<li class="mui-table-view-cell" onclick="profilePage();">
							<a id="myInfo" class="mui-navigate-right">个人信息</a>
						</li>
						<li class="mui-table-view-cell">
							<a id="tel" href="tel:123-4567-8910">客服电话：&nbsp;&nbsp;123-4567-8910</a>
						</li>
					</ul>
					<div style="height:8px;"></div>
					<ul class="mui-table-view">
						<li class="mui-table-view-cell mui-btn-danger" onclick="logout();" style="text-align: center;">
							<a id='exit'>退出</a>
						</li>
					</ul>
				</div>
			</div>
			<div style="height:44px;"></div>
		</div>
	</body>
	<script src="../js/mui.min.js"></script>
	<script src="../js/util.js"></script>
	<script>
		function bindCardFunc(){
			var url = localStorage.getItem('remoteAddress') + '/api/bindCard';
			var userName = localStorage.getItem('userName');
			mui.get(url,{
				userName: userName,
				},function(data){
					var data = data.data;
					var createCardSuccess = data.createCardSuccess;
					//alert(localStorage.getItem('userName') +' '+ createCardSuccess);
					if(createCardSuccess == '1'){
						mui.toast('生成成功');
					}else{
						mui.toast('生成失败或已经存在');
					}
				},'json'
			);
		}
		
		function bindObserverPage(){
			var url = localStorage.getItem('remoteAddress') + '/api/bindObserver';
			var userName = localStorage.getItem('userName');
			mui.get(url,{
				userName: userName,
				},function(data){
					var data = data.data;
					var pairCode = data.pairCode;
					//alert(localStorage.getItem('userName') +' '+ createCardSuccess);
					if(pairCode){
						localStorage.setItem('pairCode', pairCode);
						mui.toast('生成配对码成功');
						var bindObserverPage = plus.webview.open('bindObserverPage.html', 'bindObserverPage', {}, 'slide-in-right', 200);
					}else{
						mui.toast('生成配对码失败');
					}
				},'json'
			);
		}
		
		function bindPatientPage(){
			var bindPatientPage = plus.webview.open('bindPatientPage.html', 'bindPatientPage', {}, 'slide-in-right', 200);
		}
		
		function profilePage(){
			var url = localStorage.getItem('remoteAddress') + '/api/checkUserProfile';
			var userName = localStorage.getItem('userName');
			mui.get(url,{
				userName: userName,
				},function(data){
					var data = data.data;
					localStorage.setItem('userGender', data.gender);
					localStorage.setItem('userCity', data.city);
					localStorage.setItem('userProvince', data.province);
					localStorage.setItem('userTel', data.userTel);
				},'json'
			);
			var profilePage = plus.webview.open('profilePage.html', 'profilePage', {}, 'slide-in-right', 200);
		}
		
		function logout(){
			var url = localStorage.getItem('remoteAddress') + '/api/stopGenerateData';
			var userName = localStorage.getItem('userName');
			mui.get(url,{
				userName: userName,
				},function(data){
				},'json'
			);
			localStorage.setItem('userIn','0');
			plus.runtime.quit();
		}
	</script>
</html>
